package com.ruoyi.system.domain.vo;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

public class R implements Serializable {

    private static final long serialVersionUID = -3948389268046368059L;

    public static final String SUCCESS = "200";   //成功

    public static final String ERROR = "500";   //失败

    private Boolean success;

    private String code;

    private String msg;

    private Map<String, Object> data = new HashMap<>();

    public R() {}

    public R(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static R success() {
        R Result = new R();
        Result.setCode(SUCCESS);
        Result.setSuccess(true);
        return Result;
    }



    public static R failure() {
        R Result = new R();
        Result.setCode(ERROR);
        Result.setSuccess(false);
        return Result;
    }


    public String getCode() {
        return this.code;
    }

    public void setCode(final String code) {
        this.code = code;
    }

    public R code(final String code) {
        this.code = code;
        return this;
    }

    public String getMsg() {
        return this.msg;
    }

    public void setMsg(final String msg) {
        this.msg = msg;
    }


    public R msg(final String msg) {
        this.msg = msg;
        return this;
    }

    public Map<String, Object> getData() {
        return data;
    }

    public void setData(Map<String, Object> data) {
        this.data = data;
    }

    public R data(final String key, final Object val) {
        this.data.put(key, val);
        return this;
    }

    public Boolean getSuccess() {
        return success;
    }

    public void setSuccess(Boolean success) {
        this.success = success;
    }

    public R success(Boolean success) {
        this.success = success;
        return this;
    }

    public R dataAll(Map<String, Object> data) {
        this.data = data;
        return this;
    }
}